<?php

defined('_SECURITY_TOKEN') or die("caia fora");

abstract class framework {
	

	public function __construct(){
		

	}
	

	
	public function getSeparator(){
		return _SEPARATOR_SO;
	}
	
	public function require_file( $filename=""){
		

	}
	
	
	public function getDbMysql( ){
		
		$result	=	false;
		
		try {
        	
			$filename	=	PATH_FRAMEWORK_LIBRARY
							._SEPARATOR_SO
							."bm"
							._SEPARATOR_SO
							.'db'
							._SEPARATOR_SO
							.'mysql'
							._SEPARATOR_SO
							.'mysql'
							.'.class.php';
									
			if( file_exists( $filename ) )								
				require_once( $filename );
			else
				throw new AppException( FILE_NOT_FOUND.': '.$filename );

			$result	=	new mysql(SESSION_DB_HOST,
									SESSION_DB_USER,
									SESSION_DB_PASS,
									SESSION_DB_DATABASE);
					
	    }
	    catch (AppException $e) {
	    	throw new AppException( $e->getMessage() );
	        //echo "#1Caught TestException ('{$e->getMessage()}')\n{$e}\n";
	    }
	    catch (Exception $e) {
	        echo "#Erro Fatal ('{$e->getMessage()}')\n{$e}\n";
	    }
		
		
		return $result;
				
		
	}
	
	
	
	public function getAuthentication(){
		
		return (empty($_SESSION['user_id'])? FALSE:TRUE);

	}
	
	
	public function getAuthenticationUserName(){
		
		return (empty($_SESSION['username'])? "":$_SESSION['username']);
		
	}
	
	
	public function getUser_id(){
		
		return (empty($_SESSION['user_id'])? 0:$_SESSION['user_id']);
		
	}
	
	
	
	
	public function start_session( $typesession ){	
	
		try {
        	

			switch( $typesession ){
				
				
				case 'db':
					
					
					$filename	=	PATH_FRAMEWORK_LIBRARY
									._SEPARATOR_SO
									."bm"
									._SEPARATOR_SO
									.'session'
									._SEPARATOR_SO
									.'db'
									._SEPARATOR_SO
									.'session'
									.'.class.php';
											
					if( file_exists( $filename ) )								
						require_once( $filename );
					else
						throw new AppException( FILE_NOT_FOUND.': '
												.$filename );
			
			
					$session = new session(); 
			
					session_set_save_handler(array(&$session,"open"), 
					                         array(&$session,"close"), 
					                         array(&$session,"read"), 
					                         array(&$session,"write"), 
					                         array(&$session,"destroy"), 
					                         array(&$session,"gc")); 
					break;
				case 'file':
					
					
					break;
				default:
					
					
			}
			
						
			session_start();
			
	    }
	    catch (AppException $e) {
	    	throw new AppException( $e->getMessage() );
	        //echo "#1Caught TestException ('{$e->getMessage()}')\n{$e}\n";
	    }
	    catch (Exception $e) {
	        echo "#Erro Fatal ('{$e->getMessage()}')\n{$e}\n";
	    }
		
			
		
	}
	
}

?>